<?
require_once('bootstrap.php');
require_once('../includes/config.php');

if (DEBUG) {
	error_reporting(E_ALL); 
	ini_set('display_errors', '1');
}

// Testing write permissions (for writing configuration.php)
$config_writable = false;
$handle = @fopen('../configuration.php', 'w');
if ($handle) {
	@unlink('../configuration.php');
	$config_writable = true;
}


// Testing mod_rewrite
$use_rewrite = false;
if (function_exists('apache_get_modules')) {
	if (in_array("mod_rewrite", apache_get_modules())) {
		$use_rewrite = true;
	}
}
$_SESSION['use_rewrite'] = $use_rewrite;

$error = false;
if (!$config_writable) {
	$error = true;
}


?>

<html>
	<head>
		<title>Installation af KomitCMS</title>
		<meta http-equiv="content-type" content="text/html;charset=utf-8" />
		<meta http-equiv="Content-Style-Type" content="text/css" />
		<link rel="stylesheet" type="text/css" href="../stylesheet/style.css" />
		<link rel="stylesheet" type="text/css" href="../stylesheet/install.css" />
	</head>
	
	<body style="margin: 0">
		<div id="control">
			<button onclick="parent.previousStep()">Forige</button>
			<button onclick="<?= (!$error) ? 'parent.nextStep()' : '' ?>">Næste</button>
		</div>
		<h2 class="page-header">System tjek</h2>
		<div id="description">I dette trin undersøges din servers indstillinger, og installationsprogammet vurdere om serveren kan køre KomitCMS.</div>
		
		<div id="step" style="margin-top: 10px; padding-top: 10px; border-top: 1px solid #CCC">
			<? if ($error) { ?>
				<div style="margin: 10px 0px; padding: 10px; border: 1px solid #CCC; background: #EEE">
					Systemtesten fejlede. Listen nedenfor indikere hvilke fejl der skal rettes før installationen kan fortsætte.
				</div>
			<? } ?>
			<table width="250px">
				<tr>
					<td>Configuration.php skrivbar</td>
					<td>
						<span style="font-weight:bold;"><?= ($config_writable == true) ? 'OK' : 'FEJL' ?></span>
					</td>
				</tr>
				<tr>
					<td>Brug mod_rewrite (pænere links)</td>
					<td>
						<span style="font-weight:bold"><?= ($use_rewrite == true) ? 'JA' : 'NEJ' ?></span>
					</td>
				</tr>
			</table>
		
		</div>
		
	</body>
</html>